Int
IntegerResult = Int(FloatValue#)
 
Parameters:

    FloatValue#= The floating point variable or value to convert
Returns:

    IntegerResult = The returned integer value
 

      The Int() function converts Floating Point values, variables or expressions into an Integer data type. This process is more commonly known as casting. Sometimes it's necessary to recast Floating Point values as Integers, for use in math expressions or with certain functions / commands that may only accept Integer values (constants / variables) as parameters.



FACTS:


      * Int() can only be used upon floating point values / float variables / pointers & expressions that are of float type.

      * Floats can be recast automatically (with rounding) through any assignment between an Integer and Float. So if you assign an Integer variable a Float (and vice versa), the move operation will recast this for you. One thing to take note of though is that PlayBASIC rounds values during assignments. You can use Floor() function to avoid this if need be.




Mini Tutorial:


     Display the value of PI# with and out the using the Int() function.

  
; Display The value of PI#
  Print Pi#
  
; Display the Value of PI# as an integer.
  Print Int(pi#)
  
; Display the screen and wait for a key to be pressed
  Sync
  WaitKey
  


This example would output

  
  3.14159
  3
  


 
Related Info: BytePTR | Ceil | Float | FloatPTR | Floor | IntPTR | Pointer | Val | Variables | WordPTR :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com